#include <ctype.h>
#include <stdio.h>
#include <unistd.h>

#include "ohos_init.h"
#include "cmsis_os2.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"
#include "wifiiot_pwm.h"
#include "wifiiot_adc.h"
#include "wifiiot_i2c.h"
#include "wifiiot_errno.h"
#include "wifiiot_watchdog.h"

#include "oled.h"



void oled_task(void* arg)
{
    (void) arg;
    uint8_t str[] = {"hello harmony!"};
    WatchDogDisable();
    usleep(20*1000);
    oled_init();
    printf("oled init success\r\n");
    OLED_Clear_All();
    OLED_Show_String(0, 0, 16, str);
    OLED_ShowCHinese(0, 2, 0);
    OLED_ShowCHinese(16, 2, 1);
    OLED_ShowCHinese(32, 2, 2);
    OLED_ShowCHinese(48, 2, 3);
    printf("oled show over\r\n");
    while(1);
}

void oled_task_creat(void)
{
    osThreadAttr_t attr;

    attr.name       = "oled_task";
    attr.attr_bits  = 0U;
    attr.cb_mem     = NULL;
    attr.cb_size    = 0U;
    attr.stack_mem  = NULL;
    attr.stack_size = 10240;
    attr.priority   = osPriorityNormal1;

    if (osThreadNew(oled_task, NULL, &attr) == NULL)
    {
        printf("[oled_task_creat] Falied to create oled_task!\n");
    }
}

APP_FEATURE_INIT(oled_task_creat);
